package com.wilmer.dynamic.service.impl;

import com.wilmer.common.annotation.DataScope;
import com.wilmer.common.utils.DateUtils;
import com.wilmer.common.utils.SecurityUtils;
import com.wilmer.dynamic.domain.SysDynamic;
import com.wilmer.dynamic.mapper.SysDynamicMapper;
import com.wilmer.dynamic.service.ISysDynamicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 园内动态Service业务层处理
 *
 * @author ruoyi
 * @date 2024-04-24
 */
@Service
public class SysDynamicServiceImpl implements ISysDynamicService
{
    @Autowired
    private SysDynamicMapper sysDynamicMapper;

    /**
     * 查询园内动态
     *
     * @param dynamicId 园内动态主键
     * @return 园内动态
     */
    @Override
    public SysDynamic selectSysDynamicByDynamicId(Long dynamicId)
    {
        return sysDynamicMapper.selectSysDynamicByDynamicId(dynamicId);
    }

    /**
     * 查询园内动态列表
     *修改为数据权限为本部门以下数据权限
     */
    @DataScope(deptAlias = "d")
    @Override
    public List<SysDynamic> selectSysDynamicList(SysDynamic sysDynamic)
    {
        return sysDynamicMapper.selectSysDynamicList(sysDynamic);
    }

    /**
     * 新增园内动态
     *
     * @param sysDynamic 园内动态
     * @return 结果
     */
    @Override
    public int insertSysDynamic(SysDynamic sysDynamic)
    {
        sysDynamic.setDeptId(SecurityUtils.getDeptId());
        sysDynamic.setCreateTime(DateUtils.getNowDate());
        return sysDynamicMapper.insertSysDynamic(sysDynamic);
    }

    /**
     * 修改园内动态
     *
     * @param sysDynamic 园内动态
     * @return 结果
     */
    @Override
    public int updateSysDynamic(SysDynamic sysDynamic)
    {
        return sysDynamicMapper.updateSysDynamic(sysDynamic);
    }

    /**
     * 批量删除园内动态
     *
     * @param dynamicIds 需要删除的园内动态主键
     * @return 结果
     */
    @Override
    public int deleteSysDynamicByDynamicIds(Long[] dynamicIds)
    {
        return sysDynamicMapper.deleteSysDynamicByDynamicIds(dynamicIds);
    }

    /**
     * 删除园内动态信息
     *
     * @param dynamicId 园内动态主键
     * @return 结果
     */
    @Override
    public int deleteSysDynamicByDynamicId(Long dynamicId)
    {
        return sysDynamicMapper.deleteSysDynamicByDynamicId(dynamicId);
    }

    /**
     * 计算动态数量
     * @return
     */
    @Override
    public int sysDynamicCount(Long deptId) {
        return sysDynamicMapper.sysDynamicCount(deptId);
    }
}
